home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / cbibcode.arc / STRRCHR.C < prev    next >
Encoding:
C/C++ Source or Header  |  1991-08-05  |  433 b   |  21 lines

  1. /* strrchr.c  From TC Bible page 296  Use strrchr to find the last occurrence
  2. of a particular character in a given string */
  3.  
  4. #include <stdio.h>
  5. #include <string.h>
  6. main()
  7. {
  8.     char buf[80], *result;
  9.     printf("Enter date: ");
  10.     gets(buf);
  11.     if ((result = strrchr(buf, '/')) == NULL)
  12.     {
  13.         printf("%s <-- not a date!\n", buf);
  14.     }
  15.     else
  16.     {
  17.         result++;            /* Skip the '/' */
  18.         printf("The year is: 19%s\n", result);
  19.         }
  20. }
  21.